<?php
/**
 * 头部模板
 */
?>
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
    <meta charset="<?php bloginfo('charset'); ?>">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <?php wp_head(); ?>
</head>

<body <?php body_class('bg-[#DAE0E6] text-[#1A1A1B]'); ?>>
<?php wp_body_open(); ?>

<header class="fixed w-full z-50 h-[56px] bg-white border-b border-[#EDEFF1] <?php echo is_admin_bar_showing() ? 'top-8' : 'top-0'; ?>">
    <div class="h-full flex items-center max-w-full mx-auto px-5">
        <!-- Logo -->
        <div class="flex items-center">
            <a href="<?php echo home_url(); ?>" class="flex items-center p-2 hover:bg-[#1A1A1B]/[.04] rounded">
                <svg class="w-8 h-8" viewBox="0 0 20 20">
                    <g><circle fill="#FF4500" cx="10" cy="10" r="10"></circle><path fill="#FFF" d="M16.67,10A1.46,1.46,0,0,0,14.2,9a7.12,7.12,0,0,0-3.85-1.23L11,4.65,13.14,5.1a1,1,0,1,0,.13-0.61L10.82,4a0.31,0.31,0,0,0-.37.24L9.71,7.71a7.14,7.14,0,0,0-3.9,1.23A1.46,1.46,0,1,0,4.2,11.33a2.87,2.87,0,0,0,0,.44c0,2.24,2.61,4.06,5.83,4.06s5.83-1.82,5.83-4.06a2.87,2.87,0,0,0,0-.44A1.46,1.46,0,0,0,16.67,10Zm-10,1a1,1,0,1,1,1,1A1,1,0,0,1,6.67,11Zm5.81,2.75a3.84,3.84,0,0,1-2.47.77,3.84,3.84,0,0,1-2.47-.77,0.27,0.27,0,0,1,.38-0.38A3.27,3.27,0,0,0,10,14a3.28,3.28,0,0,0,2.09-.61A0.27,0.27,0,1,1,12.48,13.79Zm-0.18-1.71a1,1,0,1,1,1-1A1,1,0,0,1,12.29,12.08Z"></path></g>
                </svg>
                <span class="ml-2 text-[1.125rem] font-semibold leading-6 tracking-[-0.02em] text-[#1c1c1c]"><?php bloginfo('name'); ?></span>
            </a>
        </div>

        <!-- 现代化搜索框 -->
        <div class="flex-1 flex justify-center mx-6">
            <form role="search" method="get" action="<?php echo home_url(); ?>" class="relative group w-full max-w-md">
                <div class="absolute inset-y-0 left-3.5 flex items-center pointer-events-none">
                    <svg class="w-4 h-4 text-gray-400 group-hover:text-violet-500 transition-colors duration-200" viewBox="0 0 20 20" fill="currentColor">
                        <path fill-rule="evenodd" d="M8.5 3a5.5 5.5 0 100 11 5.5 5.5 0 000-11zM2 8.5a6.5 6.5 0 1111.21 4.51l4.72 4.72a.75.75 0 11-1.06 1.06l-4.72-4.72A6.5 6.5 0 012 8.5z" clip-rule="evenodd"/>
                    </svg>
                </div>
                <input type="text" 
                       name="s" 
                       class="w-full h-10 bg-green-50 backdrop-blur-lg rounded-2xl pl-10 pr-14
                              border-[1.5px] border-green-100
                              hover:border-violet-500/50 hover:bg-white/90
                              focus:border-violet-500 focus:bg-white focus:outline-none focus:ring-2 focus:ring-violet-500/20
                              text-[15px] placeholder:text-gray-400
                              transition-all duration-200 shadow-sm"
                       placeholder="搜索或输入提示词...">
                <div class="absolute inset-y-0 right-3 flex items-center space-x-1">
                    <!-- AI 图标 -->
                    <div class="flex items-center justify-center w-6 h-6 rounded-lg bg-gradient-to-r from-violet-500/10 to-fuchsia-500/10 
                                text-violet-600 group-hover:from-violet-500/20 group-hover:to-fuchsia-500/20 transition-all duration-200">
                        <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" 
                                  d="M9.5 4h5M8 7h8m-6.5 3h5M9.5 13h5m-8 3h11m-9.5 3h8"/>
                        </svg>
                    </div>
                    <!-- 快捷键提示 -->
                    <div class="hidden md:flex items-center text-xs text-gray-400 bg-green-50 
                                rounded px-1.5 py-0.5 space-x-0.5">
                        <span class="font-medium">/</span>
                    </div>
                </div>
            </form>
        </div>

        <!-- 用户菜单 -->
        <div class="flex items-center space-x-2">
            <?php if (is_user_logged_in()) : ?>
                <div class="flex items-center">
                    <button class="p-1 hover:bg-[#1A1A1B]/[.04] rounded">
                        <svg class="w-6 h-6 text-[#878A8C]" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9"></path>
                        </svg>
                    </button>
                    <div class="relative group ml-1">
                        <button class="flex items-center px-2 py-1 hover:bg-[#1A1A1B]/[.04] rounded">
                            <?php echo get_avatar(get_current_user_id(), 24, '', '', array('class' => 'w-6 h-6 rounded-full')); ?>
                            <svg class="w-5 h-5 ml-1 text-[#878A8C]" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path>
                            </svg>
                        </button>
                        <!-- 下拉菜单 -->
                        <div class="hidden group-hover:block absolute right-0 mt-1 w-64 bg-white rounded-md shadow-lg border border-[#EDEFF1]">
                            <a href="<?php echo wp_logout_url(); ?>" class="block px-4 py-2 text-sm text-gray-700 hover:bg-[#1A1A1B]/[.04]">
                                退出登录
                            </a>
                        </div>
                    </div>
                </div>
            <?php else : ?>
                <a href="<?php echo wp_login_url(); ?>" class="px-4 py-1 text-[14px] font-bold text-[#0079D3] border border-[#0079D3] rounded-full hover:bg-[#1A1A1B]/[.04]">
                    登录
                </a>
                <a href="<?php echo wp_registration_url(); ?>" class="px-4 py-1 text-[14px] font-bold text-white bg-[#0079D3] rounded-full hover:opacity-90">
                    注册
                </a>
            <?php endif; ?>
        </div>
    </div>
</header>

<div class="<?php echo is_admin_bar_showing() ? 'pt-[64px]' : 'pt-[56px]'; ?>">
    <!-- 内容区域 -->
</div>
</body>
</html> 